﻿
Public Class simpleJob
    Inherits basicJob(Of simpleJob, Int64)

    Private Shared ReadOnly field_types() As Type = Nothing

    Shared Sub New()
        field_types = New Type() {GetType(bytesByte), GetType(bytesInt64)}
    End Sub

    Public cmd As bytesByte
    Public i64 As bytesInt64

    Public Sub New()
        cmd = New bytesByte(job.command.invalid)
        i64 = New bytesInt64(0)
    End Sub

    Protected Overrides Function job_valid() As Boolean
        Return MyBase.job_valid() AndAlso job.simple.valid(+cmd)
    End Function

    Protected Overrides Function alloc() As simpleJob
        Return New simpleJob()
    End Function

    Protected Overrides Sub copy(ByVal i As simpleJob)
        assert(Not i Is Nothing)
        copy(cmd, i.cmd)
        copy(i64, i.i64)
    End Sub

    Protected Overrides Sub frombytes(ByVal paras() As fromBytes)
        assert(Not paras Is Nothing AndAlso paras.Length() = 2)
        cmd = convertor.cast(Of bytesByte)(paras(0))
        i64 = convertor.cast(Of bytesInt64)(paras(1))
    End Sub

    Protected Overrides Function hashcode_key() As Int64
        Return i64.as(Of Int64)()
    End Function

    Protected Overrides Function paras() As toBytes()
        Return New toBytes() {cmd, i64}
    End Function

    Protected Overrides Function types() As Type()
        Return field_types
    End Function
End Class
